/**
 * @Author your name
 * @Date 2021-03-04 09:23:06
 * @LastEditTime 2021-03-04 09:30:23
 * @LastEditors Please set LastEditors
 * @Description In User Settings Edit
 * @FilePath \fed-e-task-04-06\code\angular-route\src\app\guards\auth-gard.guard.ts
 */
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class AuthGardGuard implements CanActivate {
  constructor (private router: Router) {
    
  }
  canActivate(
    // 待激活路由快照
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
    // 跳转
    return this.router.createUrlTree(['/home']);
    // 允许
    // return true
    // 不允许
    // return false
  }
}
